# a='11'
# b='1'
a="1010"
b="1011"
def addBinary(a,b):
    aLen,bLen=len(a),len(b)
    a_pointer=aLen-1
    b_pointer=bLen-1
    res=""
    carry=0
    while a_pointer>=0 and b_pointer>=0:
        sumSub=int(a[a_pointer])+int(b[b_pointer])+carry
        res=str(sumSub%2)+res
        print("res:",res)
        carry=int(sumSub/2)
        print("carry:",carry)
        a_pointer-=1
        b_pointer-=1
    while a_pointer>=0:
        sumSub=int(a[a_pointer])+carry
        res=str(sumSub%2)+res
        carry=int(sumSub/2)
        a_pointer-=1
    while b_pointer>=0:
        sumSub=int(b[b_pointer])+carry
        res=str(sumSub%2)+res
        carry=int(sumSub/2)
        b_pointer-=1
    if carry:
        res=str(carry)+res
    print("最终结果："+res)
addBinary(a,b)